package com.jiukuaidao.zhulin.module.user;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.jiukuaidao.library.base.BaseActivity;
import com.jiukuaidao.library.util.ToastUtil;
import com.jiukuaidao.zhulin.R;
import com.jiukuaidao.zhulin.data.TaskProvider;
import com.jiukuaidao.zhulin.module.CommWatcher;
import com.jiukuaidao.zhulin.module.user.contract.SetPasswordContract;
import com.jiukuaidao.zhulin.module.user.presenter.SetPasswordPresenter;

import butterknife.BindView;

/**
 * Author : PaiTaSuo
 * Date : 2016/5/26
 * Description :设置密码
 */
public class SetPasswordActivity extends BaseActivity<SetPasswordContract.Presenter> implements View.OnClickListener,SetPasswordContract.View{
    @BindView(R.id.titile_left_imageview)
    ImageView mLeftImg;
    @BindView(R.id.titile_text)
    TextView mTitileText;
    @BindView(R.id.titile_right_imageview)
    ImageView mRightImg;
    @BindView(R.id.et_password)
    EditText mEtPassword;
    @BindView(R.id.et_password_again)
    EditText mEtPasswordAgain;
    @BindView(R.id.bt_save_password)
    Button mBtnSavePwd;

    @Override
    protected View getTargetView() {
        return null;
    }


    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_set_password;
    }

    @Override
    protected void handleBundle(Bundle bundle) {

    }

    @Override
    protected void init() {
        mTitileText.setText(R.string.password_set);
        setOnClickListener();
        new SetPasswordPresenter(TaskProvider.provideTasksRepository(this),this);
        mEtPasswordAgain.addTextChangedListener(new CommWatcher(mBtnSavePwd, CommWatcher.PWDLOGINBTN));
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.bt_save_password:
                mPresenter.start();
                break;
            case R.id.titile_left_imageview:
                finish();
                break;
        }
    }
    public void setOnClickListener(){
        mBtnSavePwd.setOnClickListener(this);
        mLeftImg.setOnClickListener(this);
    }

    @Override
    public String getPassword() {
        return mEtPassword.getText().toString();
    }

    @Override
    public String getRePassword() {
        return mEtPasswordAgain.getText().toString();
    }


    @Override
    public void toast(String msg) {
        ToastUtil.show(msg, Toast.LENGTH_SHORT);
    }

    @Override
    public void setFinish() {
        finish();
    }
}
